<?php

require_once 'init.php';
require_once cf\Config::path.'mail.php';

$page = cf\api\page\get('feedback');

$smarty->assign('page',$page);
$smarty->assign('pageText',cf\api\page\getText($page['id']));

if (cf\param::exist('send')) {
	$city		= trim(cf\param::get('city'));
	$person		= trim(cf\param::get('person'));
	$email		= trim(cf\param::get('email'));
	$company	= trim(cf\param::get('company'));
	$phone		= trim(cf\param::get('phone'));
	$order		= trim(cf\param::get('order'));
	
	$smarty->assign('city',$city);
	$smarty->assign('person',$person);
	$smarty->assign('email',$email);
	$smarty->assign('company',$company);
	$smarty->assign('phone',$phone);
	$smarty->assign('order',$order);

	if (!$city || !$person || !$email || !$company || !$phone || !$order) {
		$smarty->assign('error',1);
	}
	else {
		cf\Mail::send(
			'pnevmoplus@inbox.ru',
			new cf\Mail(
				'Заказ с сайта pnevmoplus.ru',
				"Компания: $company<br>".
				"Город: $city<br>".
				"Контактное лицо: $person<br>".
				"Телефон: $phone<br>".
				"Email: $email<br><br>".
				"Состав заказа:<br>$order"
			)
		);
		$smarty->assign('sent',1);
	}
}

show(
	'order', 
	$page['name'], 
	array(), 
	$page['title'], 
	$page['keywords'], 
	$page['descr']
);
?>